#!/usr/bin/php -q
<?
require('../include/dblogin.inc.php');

mysql_connect(DATA_HOST, DATA_USER, DATA_PASS);
mysql_select_db(DATA_BASE);

$oQuery = mysql_query("
	SELECT id
	FROM jobs
");
while (list($iJob) = mysql_fetch_row($oQuery)) {
	$oCountQuery = mysql_query("
		SELECT COUNT(*)
		FROM issues
		WHERE job_id = '$iJob'
	");
	list($iCount) = mysql_fetch_row($oCountQuery);
	$oUpdateQuery = mysql_query("
		UPDATE jobs
		SET issue_count = '$iCount'
		WHERE id = '$iJob'
	");
}
?>
